# Maintainer: Lukas Fleischer <lfleischer@archlinux.org>
# Contributor: Ian Denhardt <ian@zenhack.net>

_pkgname=urwidtrees
pkgname=python-urwidtrees
pkgver=1.0.3
pkgrel=9
pkgdesc="Tree widgets for urwid."
arch=(any)
url="https://github.com/pazz/$_pkgname"
license=(GPL3)
makedepends=(python-setuptools python-sphinx)
depends=(python 'python-urwid>=1.1.0')
source=("$_pkgname-$pkgver.tar.gz::https://github.com/pazz/$_pkgname/archive/$pkgver.tar.gz"
        "https://github.com/pazz/urwidtrees/commit/ed39dbc4fc67b0e0249bf108116a88cd18543aa9.patch")
sha256sums=('6e4178eac8c69237011449e5225a7b7f369b5052a0964a5b6e413fcdc1502b3a'
            '290abfba27ca1ceed14d7626d5232871bcaf8ef588f2c480a7a0544765416478')

prepare() {
	cd "$srcdir/$_pkgname-$pkgver"

    # drop unneeded mock dependency: https://github.com/pazz/urwidtrees/issues/48
    patch -p1 -i ../ed39dbc4fc67b0e0249bf108116a88cd18543aa9.patch
}

build() {
	cd "$srcdir/$_pkgname-$pkgver"
	python setup.py build
	make SPHINXBUILD=sphinx-build -C docs man html
}

package_python-urwidtrees() {
	cd "$srcdir/$_pkgname-$pkgver"

	python setup.py install --optimize=1 --root="$pkgdir"

	install -dm755 "$pkgdir/usr/share/doc/$pkgname"
	cp -a docs/build/html/* "$pkgdir/usr/share/doc/$pkgname"
}
